package com.sctvcloud.zhaohua_sd.beans;

import android.support.annotation.NonNull;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;

import com.ruihang.generalibrary.ui.util.IListData;
import com.ruihang.generalibrary.utils.IDataDate;
import com.sctvcloud.zhaohua_sd.ui.util.IListShowData;

import java.io.Serializable;
import java.sql.Date;

/**
 * Created by raoweiwei on 2017/8/15.
 */

public class FComment implements Serializable, IListShowData, IDataDate {
    private static final long serialVersionUID = -5612399370080052163L;
    private String answerTo;
    private String avatar;
    private String comment;
    private String commentId;
    private String nickName;
    private String pubTime;
    private String userId;
    private String answerToCommentId;

    private boolean isShrink;

    private Date dateTemp;
    protected int viewType;

    public String getAnswerTo() {
        return answerTo;
    }

    public void setAnswerTo(String answerTo) {
        this.answerTo = answerTo;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getCommentId() {
        return commentId;
    }

    public void setCommentId(String commentId) {
        this.commentId = commentId;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPubTime() {
        return pubTime;
    }

    public void setPubTime(String pubTime) {
        if (!TextUtils.equals(pubTime, this.pubTime)) {
            dateTemp = null;
        }
        this.pubTime = pubTime;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Override
    public String getDataTitle() {
        return comment;
    }

    @Override
    public String getDataImg() {
        return avatar;
    }

    @Override
    public String getDataTag() {
        return null;
    }

    @Override
    public String getDataId() {
        return userId;
    }

    @Override
    public int getDataType() {
        return 0;
    }

    @Override
    public int getDataViewType() {
        return viewType;
    }

    @Override
    public IListData getOwner() {
        return null;
    }

    @Override
    public String getTime() {
        return null;
    }

    @Override
    public IListShowData getOwenerData() {
        return null;
    }

    public Spanned getNameSpanned() {
        String str = "<font color=\"#f13517\">" + nickName + "</font>" + " 回复 <font color=\"#f13517\">" + answerTo + "</font>";
        return Html.fromHtml(str);
    }

    public Spanned getCommentSpanned() {
        String str = "<font color=\"#f13517\">" + nickName + "</font>" + " 回复 <font color=\"#f13517\">" + answerTo + "</font>" + " : " + comment;
        return Html.fromHtml(str);
    }

    @Override
    public Date getDataDate() {
        return dateTemp;
    }

    @Override
    public void setDataDate(Date date) {
        this.dateTemp = date;
    }

    @NonNull
    @Override
    public String getDatePattern() {
        return "yyyy-MM-dd HH:mm:ss";
    }

    @Override
    public String getDateString() {
        return pubTime;
    }

    public int getViewType() {
        return viewType;
    }

    public void setViewType(int viewType) {
        this.viewType = viewType;
    }

    public boolean isShrink() {
        return isShrink;
    }

    public void setShrink(boolean shrink) {
        isShrink = shrink;
    }

    public String getAnswerToCommentId() {
        return answerToCommentId;
    }

    public void setAnswerToCommentId(String answerToCommentId) {
        this.answerToCommentId = answerToCommentId;
    }

    @Override
    public String toString() {
        return "FComment{" +
                "answerTo='" + answerTo + '\'' +
                ", avatar='" + avatar + '\'' +
                ", comment='" + comment + '\'' +
                ", commentId='" + commentId + '\'' +
                ", nickName='" + nickName + '\'' +
                ", pubTime='" + pubTime + '\'' +
                ", userId='" + userId + '\'' +
                ", dateTemp=" + dateTemp +
                ", viewType=" + viewType +
                '}';
    }
}
